package impl.reasoning;

import impl.util.UtilityAssertion;

import java.util.Collection;
import java.util.LinkedList;

import org.semanticweb.owlapi.model.OWLNamedIndividual;

public class ChoiceResult implements Comparable<ChoiceResult> {

	private OWLNamedIndividual				choice;
	private LinkedList<UtilityAssertion>	inferredUtilityAssertions;

	public ChoiceResult(OWLNamedIndividual choice) {
		this.choice = choice;

		this.inferredUtilityAssertions = new LinkedList<UtilityAssertion>();
	}

	public void addInferredUtilityAssertion(UtilityAssertion assertion) {
		this.inferredUtilityAssertions.add(assertion);
	}

	public Collection<UtilityAssertion> getInferredUtilityAssertions() {
		return this.inferredUtilityAssertions;
	}

	public double getUtility() {
		double utility = 0;

		for (UtilityAssertion assertion : this.inferredUtilityAssertions) {
			utility += assertion.getUtilityValue();
		}

		return utility;
	}

	public OWLNamedIndividual getChoice() {
		return this.choice;
	}

	@Override
	public int compareTo(ChoiceResult o) {
		double utility1 = this.getUtility();
		double utility2 = o.getUtility();

		if (utility1 < utility2) {
			return -1;
		} else if (utility1 == utility2) {
			return 0;
		} else {
			return 1;
		}
	}

}
